******************************************************************************
*GSW TIPS data
******************************************************************************

local today=c(current_date)

*Import data from Fed website: https://www.federalreserve.gov/data/yield-curve-tables/feds200805.csv
import delimited "https://www.federalreserve.gov/data/yield-curve-tables/feds200805.csv", clear rowrange(19) delimiters(",") varnames(19)

*Save data as an Excel with today's date in name
export excel "../data/gsw_tips/raw_data/gsw_tips_`today'.xlsx", replace firstrow(variables)

*Format date
rename date date_help
gen date=date(date_help, "YMD")
format date %td
order date
drop date_help

*Keep yields and breakeven rates used in the paper 
keep date bkeven10 tipsy10 tipsy20 tipsy05

*Destring
destring *, replace ignore("NA")

*Generate 5y5y forward rate
generate tips5y5y = tipsy10  + (tipsy10 - tipsy05)
drop tipsy05

label variable bkeven10 "10yr Breakeven yield (Fed/GSW)"
label variable tipsy10 "10yr TIPS yield (Fed/GSW)"
label variable tipsy20 "20yr TIPS yield (Fed/GSW)"
label variable tips5y5y "5y5y TIPS yield (Fed/GSW)"

*Save
compress
save "../data/gsw_tips/clean_data/gsw_tips.dta", replace
